import axios from "axios";
// 创建 axios 实例
const instance = axios.create({
    baseURL:'https://reactapi.iynn.cn',
    timeout:5000,
    headers:{'Content-Type':'application/json'}
})

// 添加请求拦截器
instance.interceptors.request.use(function (config) {
  // console.log('config',config)
  const token = localStorage.getItem('token')
  if(token){
    config.headers.Authorization = token
  }
    return config;
  }, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
  });

// 添加响应拦截器
instance.interceptors.response.use(function (response) {
//   ElMessage({
//     message: response.data.statusText,
//     type:response.data.message ? 'success' : 'error',
//     duration:1000
// })
return response
  });

export default instance